<template>
  <d2-container>
    <template slot="header">执行历史</template>
    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="ID">
      </el-table-column>
      <el-table-column
        prop="appName"
        label="应用">
      </el-table-column>
      <el-table-column
        prop="jobName"
        label="任务">
      </el-table-column>
      <el-table-column
        prop="address"
        label="执行节点">
      </el-table-column>
      <el-table-column
        prop="result"
        label="执行结果">
        <template slot-scope="scope">
          <el-button :type="scope.row.result === 1? 'success': 'danger' " circle></el-button>
        </template>
      </el-table-column>
      <el-table-column
        prop="cronExpr"
        label="CRON">
      </el-table-column>
      <el-table-column
        prop="jobMethod"
        label="方法">
      </el-table-column>
      <el-table-column
        prop="jobClass"
        label="Class">
      </el-table-column>
      <el-table-column
        prop="lastFireTime"
        label="执行时间">
      </el-table-column>
    </el-table>
    <template slot="footer">
      <el-pagination
        layout="total, prev, pager, next"
        @current-change="pageChangeHandle"
        :page-size="this.page.pageSize"
        :current-page="this.page.pageNum"
        :total="this.page.total">
      </el-pagination>
    </template>
  </d2-container>
</template>

<script>
import api from '@/api'

export default {
  name: 'history',
  data () {
    return {
      tableData: [],
      page: {
        pageSize: 10,
        pageNum: 1,
        total: 0
      }
    }
  },
  methods: {
    searchUser () {
      api.LogList({ ...this.page }).then(res => {
        this.page.total = res.total
        this.tableData = res.records
      })
    },
    pageChangeHandle (currentPage) {
      this.page.pageNum = currentPage
      this.$nextTick(() => {
        this.searchUser()
      })
    }
  },
  mounted () {
    this.searchUser()
  }
}
</script>
